/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.escuela.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.escuela.modelo.Asistencia;

/**
 *
 * @author Maq-8
 */
@Stateless
public class AsistenciaDao extends AbstractDao<Asistencia> implements AsistenciaDaoLocal {

    @PersistenceContext(unitName = "Escuela-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public AsistenciaDao() {
        super(Asistencia.class);
    }

    @Override
    public boolean findByDuplicity(Asistencia assistance) {
        Query q = em.createNamedQuery("Asistencia.findByDuplicity");
        q.setParameter("fecha", assistance.getFecha());
        q.setParameter("hora", assistance.getHora());
        q.setParameter("idAlumno", assistance.getIdAlumno());
        q.setParameter("idCurso", assistance.getIdCurso());
        return !q.getResultList().isEmpty();
    }
}
